<template>
  <div class="home-container">
    <header class="main-header">
      <!-- 顶部导航栏 -->
      <nav class="navbar">
        <div class="logo">校园信息平台</div>
        <div class="nav-links">
          <a href="/messages">消息</a>
          <a href="/friends">朋友</a>
          <a href="/publish">发帖</a>

          <div v-if="isLoggedIn" class="user-profile" @click="goToMyPage">
            <img :src="userAvatar" alt="用户头像" class="avatar">
          </div>

          <div v-else class="auth-buttons">
            <a href="/login">登录</a>
            <a href="/register">注册</a>
          </div>
        </div>
      </nav>
    </header>

    <!-- 轮播图 -->
    <div class="carousel">
      <img src="/image.png" alt="轮播图">
      <div class="search-box">
        <form @submit.prevent="searchItems">
          <input v-model="searchQuery" type="text" placeholder="搜索校园信息...">
          <button type="submit">搜索</button>
        </form>
      </div>
    </div>

    <!-- 信息展示区 -->
    <div class="content">
      <!-- 校园通知网格 -->
      <div class="campus-notice">
        <div class="notice-header">
          <router-link to="/display/校园通知">
            <h2>校园通知</h2>
          </router-link>
        </div>

        <!-- 网格容器 -->
        <div class="notice-grid">
          <!-- 左侧合并区域 -->
          <div class="notice-main">
            <div class="notice-item" v-for="(item, index) in mainNotices" :key="index" @click="goToMessage">
              <span class="notice-tag">{{ item.category || item.tag }}</span>
              <span class="notice-text">{{ item.title || item.content || item.noticeTitle }}</span>
              <span class="notice-date">{{ item.createdAt || item.date }}</span>
            </div>
          </div>

          <!-- 右侧小通知区域 -->
          <div class="notice-card notice-card1">
            <img :src="defaultAvatar" alt="学术通知">
            <div class="card-content">
              <h4>学术讲座</h4>
              <p>本周五下午三点图书馆报告厅...</p>
            </div>
          </div>

          <div class="notice-card notice-card2">
            <img :src="defaultAvatar" alt="社团通知">
            <div class="card-content">
              <h4>社团招新</h4>
              <p>各大学生社团将于下周进行...</p>
            </div>
          </div>

          <div class="notice-card notice-card3">
            <img :src="defaultAvatar" alt="考试通知">
            <div class="card-content">
              <h4>期中考试</h4>
              <p>本学期期中考试定于11月15日...</p>
            </div>
          </div>

          <div class="notice-card notice-card4">
            <img :src="defaultAvatar" alt="就业通知">
            <div class="card-content">
              <h4>校园招聘</h4>
              <p>本周六就业中心将举办...</p>
            </div>
          </div>

          <div class="notice-card notice-card5">
            <img :src="defaultAvatar" alt="后勤通知">
            <div class="card-content">
              <h4>宿舍维修</h4>
              <p>近期将对南区宿舍进行...</p>
            </div>
          </div>

          <div class="notice-card notice-card6">
            <img :src="defaultAvatar" alt="体育通知">
            <div class="card-content">
              <h4>运动会报名</h4>
              <p>春季运动会报名通道已开启...</p>
            </div>
          </div>
        </div>
      </div>

      <!-- 热点话题区域 -->
      <div class="hot-topic">
        <div class="topic-header">
          <router-link :to="`/display/${encodeURIComponent('热点话题')}`">
            <h2>热点话题</h2>
          </router-link>
        </div>

        <!-- 网格容器 -->
        <div class="topic-grid">
          <!-- 左侧合并区域 -->
          <div class="topic-main">
            <div class="topic-item" v-for="(item, index) in mainTopics" :key="index">
              <span class="topic-number">TOP {{ index + 1 }}</span>
              <span class="topic-title">{{ item.title || item.topicTitle }}</span>
              <span class="topic-count">{{ item.participants || item.count || 0 }}人参与</span>
            </div>
          </div>

          <!-- 右侧话题卡片 -->
          <div v-for="(item, index) in sideTopics" :key="index" :class="['topic-card', 'topic-card' + (index + 1)]" @click="goToMessage">
            <img :src="defaultAvatar" alt="话题图片">
            <div class="card-content">
              <h4>{{ item.title || item.topicTitle }}</h4>
              <p>{{ item.description || item.desc }}</p>
            </div>
          </div>
        </div>
      </div>

      <!-- 活动信息区域 -->
      <div class="activity-section">
        <div class="activity-header">
          <router-link :to="`/display/${encodeURIComponent('活动信息')}`">
            <h2>活动信息</h2>
          </router-link>
        </div>

        <div class="activity-grid">
          <div v-for="(item, index) in activities.slice(0, 5)" :key="index" :class="['activity-card', 'activity-card' + (index + 1)]" @click="goToMessage">
            <img :src="defaultAvatar" alt="活动图片">
            <div class="card-info">
              <h3>{{ item.title || item.activityTitle }}</h3>
              <p>{{ item.description || item.desc }}</p>
            </div>
          </div>
        </div>
      </div>

      <!-- 跳蚤市场区域 -->
      <div class="flea-market">
        <div class="market-header">
          <router-link :to="`/display/${encodeURIComponent('跳蚤市场')}`">
            <h2>跳蚤市场</h2>
          </router-link>
        </div>

        <div class="market-grid">
          <div 
            v-for="(item, index) in marketItems.slice(0, 10)" 
            :key="index" 
            :class="['market-card', 'market-card' + (index + 1)]"
            @click="goToMessage"
          >
            <div class="market-image">
              <img :src="item.images && item.images.length ? item.images[0] : defaultAvatar" alt="商品图片">
              <div class="market-info">
                <h4 class="market-title">{{ item.title }}</h4>
                <p class="market-price">¥{{ item.price }}</p>
                <div class="market-description">
                  <p>{{ item.description }}</p>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>

      <!-- 学习区区域 -->
      <div class="study-zone">
        <div class="study-header">
          <router-link :to="`/display/${encodeURIComponent('学习区')}`">
            <h2>学习区</h2>
          </router-link>
        </div>

        <div class="study-container">
          <div class="study-left">
            <h3>{{ studyLeft.title }}</h3>
            <p>{{ studyLeft.description }}</p>
            <button class="study-button">立即学习</button>
          </div>

          <div class="study-right">
            <h3>{{ studyRight.title }}</h3>
            <p>{{ studyRight.description }}</p>
            <button class="study-button">查看资料</button>
          </div>
        </div>
      </div>
    </div>

    <!-- 底部 -->
    <footer class="footer">
      <p>© 2023 校园信息平台 版权所有</p>
    </footer>
  </div>
</template>

<script>
import homeApi from '@/api/home';
import apiClient from '@/utils/api.js';

export default {
  data() {
    return {
      searchQuery: '',
      searchResults: {
        posts: [],
        users: []
      },
      defaultAvatar: '/default-avatar.png',
      isLoggedIn: false,
      userAvatar: '/default-avatar.png',
      mainNotices: [], // 动态填充
      mainTopics: [],  // 动态填充
      sideTopics: [],  // 动态填充
      activities: [],  // 动态填充
      marketItems: [], // 动态填充
      studyLeft: {
        title: '热门课程推荐',
        description: '精选优质在线课程，涵盖计算机、语言、艺术等多个领域，帮助你快速提升技能。'
      },
      studyRight: {
        title: '学习资料下载',
        description: '提供各类学习资料模板、论文写作指南、考试复习重点等资源，助力你的学业发展。'
      }
    };
  },
  methods: {
    async searchItems() {
      if (this.searchQuery.trim()) {
        try {
          // 调用搜索接口
          const response = await apiClient.get(`/search/search-All?keyword=${this.searchQuery}`);
          this.searchResults = response.data;
        } catch (error) {
          console.error('搜索失败:', error);
        }
      }
    },
    goToMessage() {
      this.$router.push('/messages');
    },
    goToMyPage() {
      this.$router.push('/my');
    },
    async fetchUserInfo() {
      try {
        const response = await apiClient.get('/user/me');
        this.isLoggedIn = true;
        this.userAvatar = response.data.user?.avatar || '/default-avatar.png';
      } catch (error) {
        console.error('获取用户信息失败:', error);
        this.isLoggedIn = false;
      }
    }
  },
  created: async function () {
    const token = localStorage.getItem('token');
    if (token) {
      try {
        await this.fetchUserInfo();
      } catch (error) {
        console.error('获取用户信息失败:', error);
        this.isLoggedIn = false;
      }
    }
    try {
      // 获取校园通知（5条）
      const noticeRes = await homeApi.getCampusNotices(5);
      this.mainNotices = noticeRes.data || [];
      console.log('校园通知:', noticeRes.data);

      // 获取热门话题（10条）
      const topicRes = await homeApi.getHotTopics(10);
      const topics = Array.isArray(topicRes.data) ? topicRes.data : [];
      this.mainTopics = topics.slice(0, 3);
      this.sideTopics = topics.slice(3, 10);
      console.log('热门话题:', topicRes.data);

      // 获取活动信息（5条）
      const activityRes = await homeApi.getActivities(5);
      this.activities = activityRes.data || [];
      console.log('活动信息:', activityRes.data);

      // 获取二手市场商品（10条）
      try {
        const marketRes = await homeApi.getMarketItems(10);
        console.log('市场响应:', marketRes);
        // 直接从 marketRes.data 获取数组
        this.marketItems = Array.isArray(marketRes.data) ? marketRes.data : (marketRes.data?.data || []);
        console.log('二手市场:', this.marketItems);
      } catch (error) {
        console.error('获取二手市场数据失败:', error.response || error);
      }

      console.log('首页数据加载成功');
    } catch (error) {
      console.error('首页数据加载失败:', error);
    }
  }
};
</script>

<style scoped>
.home-container {
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 0;
}

.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #2c3e50;
  padding: 1rem 2rem;
  color: white;
}

.logo {
  font-size: 1.5rem;
  font-weight: bold;
}

.nav-links {
  display: flex;
  align-items: center;
}

.nav-links a {
  color: white;
  text-decoration: none;
  margin-left: 1.5rem;
  font-size: 1rem;
}

.user-profile {
  position: relative;
  cursor: pointer;
  display: inline-block;
  margin-left: 1.5rem;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
}


.auth-buttons a {
  margin-left: 1.5rem;
  color: white;
  text-decoration: none;
}

.carousel {
  position: relative;
  height: 500px;
  overflow: hidden;
}

.carousel img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.search-box {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60%;
  max-width: 500px;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.search-box form {
  display: flex;
  gap: 8px;
}

.search-box input[type="text"] {
  flex: 1;
  padding: 12px;
  font-size: 15px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  color: #333;
  outline: none;
  transition: all 0.2s ease;
}

.search-box input[type="text"]:focus {
  border-color: #42b983;
  box-shadow: 0 0 0 2px rgba(66, 185, 131, 0.1);
}

.search-box input[type="text"]::placeholder {
  color: #bbb;
}

.search-box button {
  padding: 12px 16px;
  font-size: 15px;
  background: #42b983;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
}

.search-box button:hover {
  background: #3a9d70;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

@media (max-width: 768px) {
  .carousel {
    height: 300px;
  }

  .search-box {
    width: 85%;
    padding: 10px;
    border-radius: 6px;
  }

  .search-box input[type="text"] {
    font-size: 14px;
    padding: 10px;
  }

  .search-box button {
    font-size: 14px;
    padding: 10px;
  }
}

.content {
  padding: 2rem;
}

.campus-notice {
  padding: 20px;
  background: #f8f9fa;
  border-radius: 12px;
  margin: 20px 0;
}

.notice-header {
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e9ecef;
}

.notice-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(2, auto);
  gap: 16px;
  position: relative;
}

/* 左侧合并区域（占据前2列和全部2行） */
.notice-main {
  grid-column: 1 / span 2;
  grid-row: 1 / span 2;
  background: white;
  padding: 16px;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.notice-item {
  display: flex;
  flex-direction: column;
  padding: 12px;
  border-bottom: 1px solid #e9ecef;
  position: relative;
}

.notice-item:last-child {
  border-bottom: none;
}

.notice-tag {
  font-size: 12px;
  color: #42b983;
  font-weight: 500;
  margin-bottom: 4px;
}

.notice-text {
  font-size: 14px;
  color: #333;
  margin-right: 40px;
}

.notice-date {
  position: absolute;
  right: 16px;
  top: 12px;
  font-size: 12px;
  color: #868e96;
}

/* 右侧小通知卡片 */
.notice-card {
  display: flex;
  align-items: center;
  padding: 12px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  transition: transform 0.2s ease;
}

.notice-card:hover {
  transform: translateY(-4px);
}

.notice-card img {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  margin-right: 12px;
}

.card-content {
  padding: 0;
}

.card-content h4 {
  font-size: 14px;
  color: #333;
  margin: 0 0 4px 0;
}

.card-content p {
  font-size: 12px;
  color: #6c757d;
  margin: 0;
}

/* 卡片位置设置 */
.notice-card1 {
  grid-area: 1 / 3 / 2 / 4;
}

.notice-card2 {
  grid-area: 1 / 4 / 2 / 5;
}

.notice-card3 {
  grid-area: 1 / 5 / 2 / 6;
}

.notice-card4 {
  grid-area: 2 / 3 / 3 / 4;
}

.notice-card5 {
  grid-area: 2 / 4 / 3 / 5;
}

.notice-card6 {
  grid-area: 2 / 5 / 3 / 6;
}

@media (max-width: 992px) {
  .notice-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .notice-main {
    grid-column: 1 / span 2;
    grid-row: 1 / span 1;
  }

  .notice-card6 {
    display: none;
  }
}

@media (max-width: 768px) {
  .notice-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .notice-main {
    grid-column: 1 / -1;
    grid-row: auto;
  }

  .notice-card {
    flex-direction: row;
  }

  .notice-card img {
    width: 32px;
    height: 32px;
    margin-right: 10px;
  }
}

.hot-topic {
  padding: 20px;
  background: #f8f9fa;
  border-radius: 12px;
  margin: 20px 0;
}

.topic-header {
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e9ecef;
}

.topic-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(2, auto);
  gap: 16px;
  position: relative;
}

/* 左侧合并区域（占据前2列和全部2行） */
.topic-main {
  grid-column: 1 / span 2;
  grid-row: 1 / span 2;
  background: white;
  padding: 16px;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.topic-item {
  display: flex;
  flex-direction: column;
  padding: 12px;
  border-bottom: 1px solid #e9ecef;
  position: relative;
}

.topic-item:last-child {
  border-bottom: none;
}

.topic-number {
  font-size: 12px;
  color: #42b983;
  font-weight: 500;
  margin-bottom: 4px;
}

.topic-title {
  font-size: 14px;
  color: #333;
  margin-right: 40px;
}

.topic-count {
  position: absolute;
  right: 16px;
  top: 12px;
  font-size: 12px;
  color: #868e96;
}

/* 右侧小话题卡片 */
.topic-card {
  display: flex;
  align-items: center;
  padding: 16px;
  background: white;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  transition: all 0.3s ease;
  border: 1px solid #e9ecef;
}

.topic-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border-color: #42b983;
}

.topic-card img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  margin-right: 16px;
  transition: all 0.3s ease;
}

.topic-card:hover img {
  transform: scale(1.05);
}

.card-content {
  padding: 0;
}

.card-content h4 {
  font-size: 14px;
  color: #333;
  margin: 0 0 4px 0;
}

.card-content p {
  font-size: 12px;
  color: #6c757d;
  margin: 0;
}

/* 卡片位置设置 */
.topic-card1 {
  grid-area: 1 / 3 / 2 / 4;
}

.topic-card2 {
  grid-area: 1 / 4 / 2 / 5;
}

.topic-card3 {
  grid-area: 1 / 5 / 2 / 6;
}

.topic-card4 {
  grid-area: 2 / 3 / 3 / 4;
}

.topic-card5 {
  grid-area: 2 / 4 / 3 / 5;
}

.topic-card6 {
  grid-area: 2 / 5 / 3 / 6;
}

@media (max-width: 992px) {
  .topic-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .topic-main {
    grid-column: 1 / span 2;
    grid-row: 1 / span 1;
  }

  .topic-card6 {
    display: none;
  }
}

@media (max-width: 768px) {
  .topic-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .topic-main {
    grid-column: 1 / -1;
    grid-row: auto;
  }

  .topic-card {
    flex-direction: row;
  }

  .topic-card img {
    width: 32px;
    height: 32px;
    margin-right: 10px;
  }
}

.activity-section {
  padding: 20px;
  background: var(--background-color);
  border-radius: var(--border-radius);
  margin: 20px 0;
  width: 100%;
}

.activity-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  width: 100%;
  box-sizing: border-box;
}

/* 卡片位置设置（仅保留前5个） */
.activity-card1 {
  grid-area: 1 / 1 / 2 / 2;
}

.activity-card2 {
  grid-area: 1 / 2 / 2 / 3;
}

.activity-card3 {
  grid-area: 1 / 3 / 2 / 4;
}

.activity-card4 {
  grid-area: 1 / 4 / 2 / 5;
}

.activity-card5 {
  grid-area: 1 / 5 / 2 / 6;
}

/* 移除多余的卡片定位规则 */
@media (max-width: 768px) {
  .activity-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }
}

.activity-card {
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
  opacity: 0.9;
}

.activity-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
  opacity: 1;
}

.activity-card img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  transition: opacity 0.3s ease;
}

.activity-card .card-info {
  padding: 16px;
}

.activity-card h3 {
  font-size: 15px;
  color: #333;
  margin: 0 0 8px 0;
}

.activity-card p {
  font-size: 13px;
  color: #6c757d;
  margin: 0;
}

/* 卡片位置设置 */
.activity-card1 {
  grid-area: 1 / 1 / 2 / 2;
}

.activity-card2 {
  grid-area: 1 / 2 / 2 / 3;
}

.activity-card3 {
  grid-area: 1 / 3 / 2 / 4;
}

.activity-card4 {
  grid-area: 1 / 4 / 2 / 5;
}

.activity-card5 {
  grid-area: 1 / 5 / 2 / 6;
}

.activity-card6 {
  grid-area: 2 / 1 / 3 / 2;
}

.activity-card7 {
  grid-area: 2 / 2 / 3 / 3;
}

.activity-card8 {
  grid-area: 2 / 3 / 3 / 4;
}

.activity-card9 {
  grid-area: 2 / 4 / 3 / 5;
}

.activity-card10 {
  grid-area: 2 / 5 / 3 / 6;
}

.activity-card11 {
  grid-area: 3 / 1 / 4 / 2;
}

.activity-card12 {
  grid-area: 3 / 2 / 4 / 3;
}

.activity-card13 {
  grid-area: 3 / 3 / 4 / 4;
}

.activity-card14 {
  grid-area: 3 / 4 / 4 / 5;
}

.activity-card15 {
  grid-area: 3 / 5 / 4 / 6;
}

@media (max-width: 992px) {
  .activity-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .activity-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.activity-grid {
  display: flex;
  gap: 1rem;
}

.activity-card {
  border: 1px solid #ddd;
  border-radius: 5px;
  overflow: hidden;
  transition: transform 0.3s;
  flex: 1;
  min-width: 0;
}

.activity-card:hover {
  transform: translateY(-5px);
}

.activity-card img {
  width: 100%;
  height: auto;
}

/* 跳蚤市场样式 */
.flea-market {
  padding: 20px;
  background: #f8f9fa;
  border-radius: 12px;
  margin: 20px 0;
}

.market-header {
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e9ecef;
}

.market-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(2, auto);
  gap: 16px;
}

/* 卡片位置设置（仅保留前10个） */
.market-card1 {
  grid-area: 1 / 1 / 2 / 2;
}

.market-card2 {
  grid-area: 1 / 2 / 2 / 3;
}

.market-card3 {
  grid-area: 1 / 3 / 2 / 4;
}

.market-card4 {
  grid-area: 1 / 4 / 2 / 5;
}

.market-card5 {
  grid-area: 1 / 5 / 2 / 6;
}

.market-card6 {
  grid-area: 2 / 1 / 3 / 2;
}

.market-card7 {
  grid-area: 2 / 2 / 3 / 3;
}

.market-card8 {
  grid-area: 2 / 3 / 3 / 4;
}

.market-card9 {
  grid-area: 2 / 4 / 3 / 5;
}

.market-card10 {
  grid-area: 2 / 5 / 3 / 6;
}

/* 移除多余的卡片定位规则 */
@media (max-width: 768px) {
  .market-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }
}

.market-card {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: white;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  transition: transform 0.3s ease;
}

.market-card:hover {
  transform: translateY(-4px);
}

.market-image {
  position: relative;
  width: 100%;
  height: 200px;
  overflow: hidden;
}

.market-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.market-card:hover .market-image img {
  transform: scale(1.05);
}

.market-info {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 12px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
  color: white;
}

.market-title {
  font-size: 14px;
  font-weight: bold;
  margin: 0 0 4px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.market-price {
  font-size: 16px;
  color: #f56c6c;
  margin: 4px 0;
  font-weight: bold;
}

.market-description {
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.3s ease;
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.market-card:hover .market-description {
  opacity: 1;
}

/* 学习区样式 */
.study-zone {
  padding: 20px;
  background: #f8f9fa;
  border-radius: 12px;
  margin: 20px 0;
}

.study-header {
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e9ecef;
}

.study-container {
  display: flex;
  justify-content: space-between;
  gap: 20px;
}

.study-left,
.study-right {
  flex: 1;
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  transition: transform 0.3s ease;
}

.study-left:hover,
.study-right:hover {
  transform: translateY(-4px);
}

.study-button {
  margin-top: 16px;
  padding: 10px 16px;
  font-size: 14px;
  background: #42b983;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.3s ease;
}

.study-button:hover {
  background: #3a9d70;
}

@media (max-width: 768px) {
  .study-container {
    flex-direction: column;
  }
}

.footer {
  background-color: #2c3e50;
  color: white;
  text-align: center;
  padding: 1rem;
  margin-top: 2rem;
}

.main-nav {
  display: flex;
  gap: 15px;
}

.main-nav a {
  color: #fff;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.main-nav a:hover {
  background-color: rgba(255, 255, 255, 0.2);
}
</style>
